package com.dc.designPattern._3_prototype.improve;

/**
 * Description: 测试客户端
 *
 * 克隆羊问题：
 *    现在有一只羊 tom， 姓名为: tom, 年龄为： 1， 颜色为： 白色， 请编写程序创建和 tom 羊 属性完全相同的 10 只羊。
 *
 * @author: gdc
 * @date: 2021/3/8
 * @version 1.0
 */
public class Client {

	public static void main(String[] args) {
		Sheep firend = new Sheep("jieke", 5, "黑色");
		// 初始绵羊
		Sheep sheep = new Sheep("tom", 1, "白色", firend);

		// 对象信息Copy
		Sheep sheep2 = (Sheep) sheep.clone();
		Sheep sheep3 = (Sheep) sheep.clone();
		Sheep sheep4 = (Sheep) sheep.clone();
		Sheep sheep5 = (Sheep) sheep.clone();

		System.out.println(sheep + ",\tcode = " + sheep.hashCode() + "\tfirendCode = " + sheep.getFirend().hashCode());
		System.out.println(sheep2 + ",\tcode = " + sheep2.hashCode() + "\tfirendCode = " + sheep2.getFirend().hashCode());
		System.out.println(sheep3 + ",\tcode = " + sheep3.hashCode() + "\tfirendCode = " + sheep3.getFirend().hashCode());

		sheep3.getFirend().setAge(8);
		System.out.println(sheep4 + ",\tcode = " + sheep4.hashCode() + "\tfirendCode = " + sheep4.getFirend().hashCode());
		System.out.println(sheep5 + ",\tcode = " + sheep5.hashCode() + "\tfirendCode = " + sheep5.getFirend().hashCode());
	}

}
